{% extends "base.html" %}
{% block css -%}
<style type="text/css">
.odd{
    background-color:#f0f0f0;
}
.even{
    background-color:#e5e5e5;
}
</style>
{% endblock -%}
{% block menubar -%}
{% endblock -%}
{% block content -%}
{% if books and books.count()>0 -%}
<p style="text-align:center;color:red;font-weight:bold;">Books</p>
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
    <thead>
    <tr>
        <th class="center">ID</th>
        <th class="center">Title</th>
        <th class="center">Users</th>
        <th class="center">Builtin</th>
        <th class="center">Language</th>
    </tr>
    </thead>
    <tbody>
    {% for item in books -%}
    <tr class={{loop.cycle("odd","even")}}>
        <td class="center">{{item.key().id()}}</td>
        <td class="center">{{item.title}}</td>
        <td class="center">{{item.users}}</td>
        <td class="center">{{item.builtin}}</td>
        <td class="center">{%if not item.builtin%}{{item.language}}{%else%}-{%endif%}</td>
    </tr>
    {% endfor -%}
    </tbody>
</table>
{% endif -%}
{% if users and users.count()>0 -%}
<hr />
<p style="text-align:center;color:red;font-weight:bold;">Users</p>
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
    <thead>
    <tr>
        <th class="center">ID</th>
        <th class="center">Name</th>
        <th class="center">Email</th>
        <th class="center">Enable</th>
        <th class="center">Book</th>
        <th class="center">Timezone</th>
        <th class="center">Titlefmt</th>
        <th class="center">Expires</th>
    </tr>
    </thead>
    <tbody>
    {% for item in users -%}
    <tr class={{loop.cycle("odd","even")}}>
        <td class="center">{{item.key().id()}}</td>
        <td class="center">{{item.name}}</td>
        <td class="center">{{item.kindle_email}}</td>
        <td class="center">{{item.enable_send}}</td>
        <td class="center">{{item.book_type}}</td>
        <td class="center">{{item.timezone}}</td>
        <td class="center">{{item.titlefmt}}</td>
        <td class="center">{%if item.expires%}{{item.expires.strftime("%Y-%m-%d")}}
            {%else%}-{%endif%}</td>
    </tr>
    {% endfor -%}
    </tbody>
</table>
{% endif -%}
{% if feeds and feeds.count()>0 -%}
<hr />
<p style="text-align:center;color:red;font-weight:bold;">Feeds</p>
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
    <thead>
    <tr>
        <th class="center">ID</th>
        <th class="center">Book</th>
        <th class="center">Title</th>
        <th class="center">URL</th>
        <th class="center">FullText</th>
    </tr>
    </thead>
    <tbody>
    {% for item in feeds -%}
    <tr class={{loop.cycle("odd","even")}}>
        <td class="center">{{item.key().id()}}</td>
        <td class="center">{{item.book.title}}</td>
        <td class="center">{{item.title}}</td>
        <td class="center">{{item.url[:20]}}..</td>
        <td class="center">{%if item.isfulltext%}<span style="color:red;">1</span>
            {%else%}0{%endif%}</td>
    </tr>
    {% endfor -%}
    </tbody>
</table>
{% endif -%}
{% if urlencs and urlencs.count()>0 -%}
<hr />
<p style="text-align:center;color:red;font-weight:bold;">UrlEncoding</p>
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
    <thead>
    <tr>
        <th class="center">ID</th>
        <th class="center">Host</th>
        <th class="center">FeedEncoding</th>
        <th class="center">PageEncoding</th>
    </tr>
    </thead>
    <tbody>
    {% for item in urlencs -%}
    <tr class={{loop.cycle("odd","even")}}>
        <td class="center">{{item.key().id()}}</td>
        <td class="center">{{item.netloc}}</td>
        <td class="center">{% if item.feedenc %}{{item.feedenc}}{% else %}-{% endif %}</td>
        <td class="center">{% if item.pageenc %}{{item.pageenc}}{% else %}-{% endif %}</td>
    </tr>
    {% endfor -%}
    </tbody>
</table>
{% endif -%}
{% endblock -%}
